<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require_once 'app/config/dbconfig.php' ;
class Access_Db extends Config_DbConfig
{
    private $connection ;
    private $dbSelect;
    
    function __construct()
    {
        $this->openConnection() ;
    }
    
    private function openConnection()
    {
        
            $this->connection = mysql_connect($this->host,
            $this->user,
            $this->password) ;
            
            if (!$this->connection) {
        
                throw new Exception ('db connection failed!!!') ;
            } else {
                $this->dbSelect = mysql_select_db($this->dbName) ;
                if (!$this->dbSelect) { die("Database selection failed: ".
                        mysql_error()) ; }
            }
    }
    
    
    public function getConnection()
    {
        return $this->connection ;

    }
    
    public function executeQuery($query)
    {
        
        $result = mysql_query($query) ;
        if(!$result) {
            die("Database query failed: ".mysql_error()) ;
	}
	return $result ;
        
    }
}

?>
